package com.atguigu.sta.scheduled;

import com.atguigu.sta.service.StatisticsDailyService;
import com.atguigu.sta.utils.DateUtil;
import com.sun.org.apache.bcel.internal.generic.DUP;
import org.junit.Test;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

@Component
public class ScheduledTask {

    @Resource
    private StatisticsDailyService statisticsDailyService;
    @Scheduled(cron = "0 0 1 1-31 * ?")
    public void autoStatisticsDaily(){
         statisticsDailyService.getCountRegister(
                 DateUtil.formatDate(DateUtil.addDays(new Date(),-1)));
    }

    // 0/5 * * * * ? *  springBoot中只能写6位不然会报错
//    @Scheduled(cron = "0/5 * * * * ? ")
//    public void test(){
//        System.out.println(new Date()+"********test");
//    }
}
